<?php
/*
 * 用车手册列表页加载文件
 * @package    manual
 * @author     Mark
 * @copyright  Copyright (c) 2013 ixdcw team
 * @version    $Id: 5fb2f45bc594cf88aec217f96aa110eb3535a71d $
 */
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.MODULE_NAME.'/common.inc.php';
// 检测类别是否和模块符合
if(!empty($CAT) && $CAT['moduleid'] != $moduleid) {
	$head_title = lang('message->cate_not_exists');
	@header("HTTP/1.1 404 Not Found");
	exit(include template('list-notfound', 'message'));
}

$maincat = get_maincat(0, $moduleid);
$buildBase = array('catid');
// 初始化条件
$condition = ' 1 ';
$condition .= ' and (status=3 or status=2)';

// 子分类内容筛选
if (!empty($CAT)) {
	$condition .= ($CAT['child']) ? " AND catid IN (".$CAT['arrchildid'].")" : " AND catid=$catid";
}
if ($kw) {
	$condition .= " AND title LIKE '%$kw%'";
}
// 条目计算
if (empty($CAT)) {
	$total = $db->count($table , $condition, $CFG['db_expires']);
} else {
	if($page == 1) {
		$total = $db->count($table, $condition, $CFG['db_expires']);
		if(!empty($CAT) && $total != $CAT['item']) {
			// 更新数量
			$CAT['item'] = $total;
			$db->query("UPDATE {$db->getPre()}category SET item=$total WHERE catid=$catid");
		}
	} else{
		$total = $CAT['item'];
	}
}


// 模块的分页数
$do = new ManualModule($moduleid);
$tags = array();

if($total) {
	$tags = $do->getList($condition);
}
$seo_file = 'list';
include DT_INC.'/seo.inc.php';
$template = $CAT['template'] ? $CAT['template'] : ($MOD['template_list'] ? $MOD['template_list'] : 'list');
include template($template, MODULE_NAME);